package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.CaseClaimPhoto;
import com.ktgj.customer.service.ICaseClaimPhotoService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 理赔工单凭证图片Controller
 * 
 * @author ruoyi
 * @date 2022-05-25
 */
@RestController
@RequestMapping("/photo")
public class CaseClaimPhotoController extends BaseController
{
    @Autowired
    private ICaseClaimPhotoService caseClaimPhotoService;

    /**
     * 查询理赔工单凭证图片列表
     */
    @PreAuthorize(hasPermi = "system:photo:list")
    @GetMapping("/list")
    public TableDataInfo list(CaseClaimPhoto caseClaimPhoto)
    {
        startPage();
        List<CaseClaimPhoto> list = caseClaimPhotoService.selectCaseClaimPhotoList(caseClaimPhoto);
        return getDataTable(list);
    }

    /**
     * 导出理赔工单凭证图片列表
     */
    @PreAuthorize(hasPermi = "system:photo:export")
    @Log(title = "理赔工单凭证图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CaseClaimPhoto caseClaimPhoto) throws IOException
    {
        List<CaseClaimPhoto> list = caseClaimPhotoService.selectCaseClaimPhotoList(caseClaimPhoto);
        ExcelUtil<CaseClaimPhoto> util = new ExcelUtil<CaseClaimPhoto>(CaseClaimPhoto.class);
        util.exportExcel(response, list, "理赔工单凭证图片数据");
    }

    /**
     * 获取理赔工单凭证图片详细信息
     */
    @PreAuthorize(hasPermi = "system:photo:query")
    @GetMapping(value = "/{caseClaimPhotoId}")
    public AjaxResult getInfo(@PathVariable("caseClaimPhotoId") Long caseClaimPhotoId)
    {
        return AjaxResult.success(caseClaimPhotoService.selectCaseClaimPhotoById(caseClaimPhotoId));
    }

    /**
     * 新增理赔工单凭证图片
     */
    @PreAuthorize(hasPermi = "system:photo:add")
    @Log(title = "理赔工单凭证图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CaseClaimPhoto caseClaimPhoto)
    {
        return toAjax(caseClaimPhotoService.insertCaseClaimPhoto(caseClaimPhoto));
    }

    /**
     * 修改理赔工单凭证图片
     */
    @PreAuthorize(hasPermi = "system:photo:edit")
    @Log(title = "理赔工单凭证图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CaseClaimPhoto caseClaimPhoto)
    {
        return toAjax(caseClaimPhotoService.updateCaseClaimPhoto(caseClaimPhoto));
    }

    /**
     * 删除理赔工单凭证图片
     */
    @PreAuthorize(hasPermi = "system:photo:remove")
    @Log(title = "理赔工单凭证图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{caseClaimPhotoIds}")
    public AjaxResult remove(@PathVariable Long[] caseClaimPhotoIds)
    {
        return toAjax(caseClaimPhotoService.deleteCaseClaimPhotoByIds(caseClaimPhotoIds));
    }
}
